package com.briup.web.controller;

import com.briup.DTO.AddOrUpdateFenceHouseDTO;
import com.briup.DTO.AddOrUpdateQuarantimeRegistraionDTO;
import com.briup.annotation.SystemLog;
import com.briup.exception.SystemException;
import com.briup.mapper.QuarantineRegistrationMapper;
import com.briup.result.PageTemplate;
import com.briup.result.Result;
import com.briup.service.QuarantineRegistrationService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/quarantineRegistration")
public class QuarantineRegistrationController {
    @Autowired
    private QuarantineRegistrationService quarantineRegistrationService;
    @GetMapping("/query")
    @ApiOperation("分页并根据条件查询检疫记录接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页大小"),
            @ApiImplicitParam(name = "bQualified",value = "检疫结果：合格或不合格"),
            @ApiImplicitParam(name = "grMechanism",value = "检疫机构，支持模糊查询")
    })
    public Result query(Integer pageNum,Integer pageSize,String bQualified,String grMechanism) throws SystemException {
        PageTemplate pageTemplate=quarantineRegistrationService.qrquery(pageNum,pageSize,bQualified,grMechanism);
        return Result.success(pageTemplate);
    }
    @PostMapping("/saveOrUpdate")
    @ApiOperation("新增或更新检疫记录接口")
    @SystemLog(business = "新增或更新检疫记录")
    public Result saveOrUpdate(@RequestBody AddOrUpdateQuarantimeRegistraionDTO addOrUpdateQuarantimeRegistraionDTO) throws SystemException {
        return quarantineRegistrationService.QRSaveOrUpdate(addOrUpdateQuarantimeRegistraionDTO);
    }

    @DeleteMapping("/deleteById")
    @ApiOperation("根据id删除检疫信息接口")
    @SystemLog(business = "根据id删除检疫信息")
    public Result deleteById(@PathVariable String id) throws SystemException {
        return quarantineRegistrationService.deleteById(id);
    }
    @DeleteMapping("deleteByIdAll")
    @ApiOperation("批量删除检疫信息接口")
    @SystemLog(business = "批量删除检疫信息")
    public Result deleteByIdAll(@RequestBody List<String> ids) throws SystemException {
        return quarantineRegistrationService.deleteByIdAll(ids);
    }
}